package cn.wolfcode.luowowo.search.query;

import cn.wolfcode.luowowo.common.query.QueryObject;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

@Setter
@Getter
public class SearchQueryObject extends QueryObject{


    public static final int CONDITION_TYPE_UN_ABROAD =1 ;//国内
    public static final int CONDITION_TYPE_ABROAD =0 ;//国外
    public static final int CONDITION_TYPE_THEME =2 ;//主题

    private Long destId = -1L;
    //这里写死一个点击数,然后前台如果传入的是更新时间的话就会自动覆盖,所以在QO 里面就一定要写这个字段
    private String orderBy = "viewnum";
    private int type = -1; //查询的条件 国家 省份 主题 关键字
    private int typeValue = -1; //条件下面的值

    public Pageable getPageable(){
        PageRequest of = PageRequest.of(super.getCurrentPage()-1, super.getPageSize(), Sort.Direction.DESC, orderBy);
        return of;
    }

    public Pageable getPageableWithoutSort(){
        PageRequest of = PageRequest.of(super.getCurrentPage()-1, super.getPageSize());
        return of;
    }


}
